package com.hliushi.demo.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 过滤所有提交到服务器的请求参数
 *
 * @author llhuang10
 * @date 2021/8/24 17:07
 */
public class XSSFilter implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        // 传入重写后的Request
        chain.doFilter(new XssRequestWrapper(httpServletRequest), response);
    }

    @Override
    public void destroy() {

    }
}
